import numpy as np

a = np.array([1, 2, 3], np.int32)

# 方法1: append() 追加
a = np.append(a, 4)
print(a)
""" [1 2 3 4] """

# 方法2: concatenate() 拼接
new_data = np.array([5], dtype=np.int32)
a = np.concatenate((a, new_data))
print(a)
""" [1 2 3 4 5] """

# 方法3: resize() 重置大小, 给元素赋值
a = np.resize(a, len(a) + 1)
a[-1] = 6
print(a)
""" [1 2 3 4 5 6] """